package cn.tedu.d17_thread;
/*
 Runnable方法 创建售票案例
 */
public class Test4_SaleTickets2 {
    public static void main(String[] args) {
        SaleRunnable target=new SaleRunnable();

        Thread t1=new Thread(target,"1号窗口");
        Thread t2=new Thread(target,"2号窗口");
        Thread t3=new Thread(target,"3号窗口");
        Thread t4=new Thread(target,"4号窗口");
        t1.start();
        t2.start();
        t3.start();
        t4.start();

    }
}

class SaleRunnable implements Runnable{
    static int tickets=100;

    @Override
    public void run() {
        while (true){
            System.out.println(Thread.currentThread().getName()+"="+tickets--);
            if (tickets<=0) break;
        }
    }
}
